# WRF project task catalogue aggregator
#
# Splits roadmap items into streams representing the two major sub-projects
# (WRF-MCV and WRF-SEM) plus shared foundation and programme glue. Tasks
# derive from the sources enumerated in wrf-proposal.log.

ifndef PROJECT_CATALOG_DIR
PROJECT_CATALOG_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
endif
PROJECT_ROOT ?= /home/linden/code/julia/WRF
WRF_DOC_ROOT ?= $(PROJECT_ROOT)
WRF_REF_PATHS := $(WRF_DOC_ROOT) $(PROJECT_CATALOG_DIR)
WRF_SUCCESS_DIR := logs/wrf/success

define WRF_FIND_REF
$(strip $(firstword $(foreach dir,$(WRF_REF_PATHS),$(if $(wildcard $(dir)/$(1)),$(dir)/$(1)))))
endef

WRF_REF = $(strip $(if $(call WRF_FIND_REF,$(1)),$(call WRF_FIND_REF,$(1)),$(error WRF reference not found: $(1) (searched $(WRF_REF_PATHS)))))

# Stream catalogues
include $(PROJECT_CATALOG_DIR)streams/foundation.mk
include $(PROJECT_CATALOG_DIR)streams/wrf_mcv_new.mk
include $(PROJECT_CATALOG_DIR)streams/wrf_mcv_existing.mk
include $(PROJECT_CATALOG_DIR)streams/wrf_sem_new.mk
include $(PROJECT_CATALOG_DIR)streams/wrf_sem_existing.mk
include $(PROJECT_CATALOG_DIR)streams/program.mk

# Task dependencies
$(call REGISTER_DEP,WRF_FOUND_AAC,WRF_FOUND_A1)
$(call REGISTER_DEP,WRF_FOUND_AAC,WRF_FOUND_A2)
$(call REGISTER_DEP,WRF_FOUND_AAC,WRF_FOUND_A3)
$(call REGISTER_DEP,WRF_FOUND_AAC,WRF_FOUND_A4)

$(call REGISTER_DEP,WRF_MCV_NEW_B1,WRF_FOUND_AAC)
$(call REGISTER_DEP,WRF_MCV_NEW_B2,WRF_MCV_NEW_B1)
$(call REGISTER_DEP,WRF_MCV_NEW_B3,WRF_MCV_NEW_B2)
$(call REGISTER_DEP,WRF_MCV_NEW_B4,WRF_MCV_NEW_B3)
$(call REGISTER_DEP,WRF_MCV_NEW_B5,WRF_MCV_NEW_B4)
$(call REGISTER_DEP,WRF_MCV_NEW_B6,WRF_MCV_NEW_B5)
$(call REGISTER_DEP,WRF_MCV_NEW_BAC,WRF_MCV_NEW_B6)

$(call REGISTER_DEP,WRF_SEM_NEW_C1,WRF_FOUND_AAC)
$(call REGISTER_DEP,WRF_SEM_NEW_C2,WRF_SEM_NEW_C1)
$(call REGISTER_DEP,WRF_SEM_NEW_C3,WRF_SEM_NEW_C2)
$(call REGISTER_DEP,WRF_SEM_NEW_C4,WRF_SEM_NEW_C3)
$(call REGISTER_DEP,WRF_SEM_NEW_C5,WRF_SEM_NEW_C4)
$(call REGISTER_DEP,WRF_SEM_NEW_C6,WRF_SEM_NEW_C5)
$(call REGISTER_DEP,WRF_SEM_NEW_CAC,WRF_SEM_NEW_C6)

$(call REGISTER_DEP,WRF_SHARED_GOAL,WRF_MCV_NEW_BAC)
$(call REGISTER_DEP,WRF_SHARED_GOAL,WRF_SEM_NEW_CAC)

$(call REGISTER_DEP,WRF_SE_PHASEB_OPT1,WRF_SE_PHASEB5)
$(call REGISTER_DEP,WRF_SE_PHASEBAC,WRF_SE_PHASEB_OPT1)
$(call REGISTER_DEP,WRF_SE_PHASEC_OPT1,WRF_SE_PHASEC1_5)
$(call REGISTER_DEP,WRF_SE_PHASEC_OPT2,WRF_SE_PHASEC1_3)
$(call REGISTER_DEP,WRF_SE_PHASECAC,WRF_SE_PHASEC1_6)
$(call REGISTER_DEP,WRF_SE_PHASED_OPT1,WRF_SE_PHASEDAC)
$(call REGISTER_DEP,WRF_SE_GOAL,WRF_SE_PHASECAC)
